<?php
header("content-type:text/html;charset=utf-8");
//$_FILES
//print_r($_FILES);
$filename=$_FILES['myFile']['name'];
$type=$_FILES['myFile']['type'];
$tmp_name=$_FILES['myFile']['tmp_name'];
$error=$_FILES['myFile']['error'];
$size=$_FILES['myFile']['size'];
$destination="uploads/".$filename;//文件上传保存路径；
if($error==UPLOAD_ERR_OK){
    //需要判断下文件是否通过HTTP POST方式上传过来的；
    //is_upoaded_file($tmp_name);
    if(is_uploaded_file($tmp_name)){
       if(move_uploaded_file($tmp_name,$destination)){
	    	$mes="文件上传成功";
	    }else{
	    	$mes="文件上传失败";
	    }	
    }
    
}else{
	switch ($error) {
		case 1:
		    $mes="超过啦配置文件上传文件的大小";
			# code...
			break;
		case 2:
		    $mes="超过表单设置上传大小";
		    break;
		case 3:
		    $mes="文件部分被上传";
		    break;
		case 4:
		    $mes="没有文件上传";
			# code...
			break;
		case 6:
		    $mes="没有找到临时文件目录";
			# code...
			break;
		case 7:
		    $mes="文件不可写";
			# code...
			break;
		case 8:
		    $mes="由于PHP的扩展程序中断啦文件上传";
			# code...
			break;
		default:
			# code...
			break;
	}
}


echo $mes;

